/*
 * 项目名：CreditHC-Account-Data
 * 类路径：com.credithc.account.common.DataEntity
 * 文件名：DataEntity.java
 * @Copyright (c) 2017  Inc. All rights reserved
 */
package com.flash.dataU.test.entity;

import com.flash.dataU.test.util.PageInfo;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import org.hibernate.validator.constraints.Length;

/**
 * 数据Entity类
 *
 * @author sunyiming (sunyiming170619@credithc.com)
 * @version 0.0.1-SNAPSHOT
 * @since 2017年07月25日 14时17分
 */
public abstract class DataEntity<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final String dbName = "mysql";

    /**
     * 创建日期.
     */
    protected Timestamp createTime;
    /**
     * 更新日期.
     */
    protected Timestamp updateTime;
    /**
     * 开始 创建时间(查询条件).
     */
    private Date beginCreateTime;
    /**
     * 结束 创建时间(查询条件).
     */
    private Date endCreateTime;

    /**
     * 分页信息
     */
    private PageInfo pageInfo;

    /**
     * 操作人ID.
     */
    private String opId;

    public DataEntity() {
        super();
    }

    /**
     * 插入之前执行方法，需要手动调用
     */
    public void preInsert() {
        this.updateTime = new Timestamp(System.currentTimeMillis());
        this.createTime = this.updateTime;
    }

    public boolean getIsNewRecord() {
        return null == getId();
    }

    public abstract Long getId();

    public abstract void setId(Long id);

    /**
     * 更新之前执行方法，需要手动调用
     */
    public void preUpdate() {
        this.updateTime = new Timestamp(System.currentTimeMillis());
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    public Date getBeginCreateTime() {
        return beginCreateTime;
    }

    public void setBeginCreateTime(Date beginCreateTime) {
        this.beginCreateTime = beginCreateTime;
    }

    public Date getEndCreateTime() {
        return endCreateTime;
    }

    public void setEndCreateTime(Date endCreateTime) {
        this.endCreateTime = endCreateTime;
    }

    @Length(min = 0,
        max = 50,
        message = "操作人ID长度必须介于 0 和 50 之间")
    public String getOpId() {
        return opId;
    }

    public void setOpId(String opId) {
        this.opId = opId;
    }

    public PageInfo getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo pageInfo) {
        this.pageInfo = pageInfo;
    }
}
